using System.Collections.Generic;
using FlexiCommerce.Components;

namespace FlexiCommerce.Collections
{
	/// <summary>
	/// Wraps and inverses another filter.
	/// </summary>
	public class InverseFilter : ItemFilter
	{
		private ItemFilter filterToInverse;

		public InverseFilter(ItemFilter filterToInverse)
		{
			this.filterToInverse = filterToInverse;
		}

		public override bool Match(PersistenceItem item)
		{
			return !filterToInverse.Match(item);
		}

        public static void FilterInverse(IList<PersistenceItem> items, ItemFilter filterToInverse)
		{
			Filter(items, new InverseFilter(filterToInverse));
		}
	}
}